// 引入
const http = require('http')
const path = require('path')
const fs = require('fs')
// 创建浏览器
let sever = http.createServer()
// 开启浏览器
sever.listen(5555, () => {
  console.log('开启了')
})
// 监听
sever.on('request', (req, res) => {
  if (req.url === '/' || req.url === '/index.html') {
    let path1 = path.join(__dirname, './index.html')
    fs.readFile(path1, (err, data) => {
      res.end(data)
    })
  } else if (req.url === '/index.css') {
    let path2 = path.join(__dirname, './index.css')
    fs.readFile(path2, (err, data) => {
      res.end(data)
    })
  } else if (req.url === '/index.js') {
    let path3 = path.join(__dirname, './index.js')
    fs.readFile(path3, (err, data) => {
      res.end(data)
    })
  } else {
    res.end(404)
  }
  // res.end('123')
})
